// 城市选择栏下拉菜单
(function(){
	var oHide = document.getElementById("hide_site");
	var oCitysel = document.getElementsByClassName("citysel")[0];
	var oSite = document.getElementById("site");
	var oProvicesel = document.getElementsByClassName("provicesel")[0];
	oSite.onmouseover = oHide.onmouseover = function(){
		oHide.style.display = "block";
		oSite.style.backgroundColor = "white";
		}
		var i = 0;
		oProvicesel.onclick = function(){			
			i ++;
			if(i % 2 == 1){
				oCitysel.style.display = "block";
			}else{
				oCitysel.style.display = "none";
			}
	}
	oSite.onmouseout = oHide.onmouseout = function(){
		oHide.style.display = "none";
		oSite.style.backgroundColor = "#EEEEEE";
	}
	//果园公告下拉菜单
		$("#notice").mouseover(function(){
			$("#notice_hide").css("display","block");
			$("#notice").css("background","#ffffff");
		})
		$("#notice_hide").mouseover(function(){
			$("#notice_hide").css("display","block");
			$("#notice").css("background","#ffffff");
		})
		$("#notice").mouseout(function(){
			$("#notice_hide").css("display","none");
			$("#notice").css("background","#eeeeee");
		})
		$("#notice_hide").mouseout(function(){
			$("#notice_hide").css("display","none");
			$("#notice").css("background","#eeeeee");
		})	
		
	//手机果园下拉菜单
		$("#li_2").mouseover(function(){
			$("#phone_hide").css("display","block");
			$("#li_2").css("background","#ffffff");
		})
		$("#phone_hide").mouseover(function(){
			$("#phone_hide").css("display","block");
			$("#li_2").css("background","#ffffff");
		})
		$("#li_2").mouseout(function(){
			$("#phone_hide").css("display","none");
			$("#li_2").css("background","#eeeeee");
		})
		$("#phone_hide").mouseout(function(){
			$("#phone_hide").css("display","none");
			$("#li_2").css("background","#eeeeee");
		})
		
	//banner图下方图片获取地址
	$.getJSON('json/Home.json',function(response,status,xhr){
		$(".show img").each(function(i){
			$(".show img").eq(i).attr("src",src = response.show[i]);
		})
	})
		
	//果园推荐图片
	$.getJSON('json/Home.json',function(response,status,xhr){
		//alert(status);
		$("#recommend_r dl dt img").each(function(i){
			$("#recommend_r dl dt img").eq(i).attr("src",src = response.recommend[i]);
		})
	})
	
	
	//添加产品至购物车
	var oC_img = document.getElementsByClassName("c_img")[0];
	oC_img.onclick = function(){
		createCookie("product_code","0001");
	}
	
	function createCookie(key, value, expires, pa, domain, secure) {
		var cookieText = encodeURIComponent(key) + "=" + encodeURIComponent(value) + ";path=/path/";
		if(!isNaN(expires)) {
			if(typeof expires == "number" && expires > 0) {
				var date = new Date();
				date.setDate(date.getDate() + expires);
				cookieText += ";expires=" + date;
			}
		}
		if(domain) {
			cookieText += ";domain=" + domain;
		}
		if(secure) {
			cookieText += ";secure";
		}
		document.cookie = cookieText;
	}
	
	
	
})()

	


